#include "head.h"


int do_register(client_status_t *status){

    char username[60]={0};
    char password[60]={0};
    char path[60]={0};

    printf("输入用户名:");
    scanf("%s",username);
    printf("输入密码:");
    scanf("%s",password);

    char ch;
    while((ch=getchar())!='\n');
    strcpy(path,"/");
    strcat(path,username);
    char clcmd[15]="/";

    //send用户信息
    self_defined_pro_t *mes=(self_defined_pro_t *)calloc(1,sizeof(self_defined_pro_t));
    strcpy(mes->message,"path=");
    strcat(mes->message,username);
    strcat(mes->message,"&");
    strcat(mes->message,"username=");
    strcat(mes->message,username);
    strcat(mes->message,"&");
    strcat(mes->message,"password=");
    strcat(mes->message,password);
    mes->cmd=regis;
    mes->message_len=strlen(mes->message);
    mes->para_num=3;
    int ret = send(status->socket_fd,mes,sizeof(self_defined_pro_t),MSG_NOSIGNAL);
    ERROR_CHECK(ret, -1, "send");


    self_defined_pro_t *server_mes=(self_defined_pro_t *)calloc(1,sizeof(self_defined_pro_t));
    recv(status->socket_fd,server_mes,sizeof(self_defined_pro_t),MSG_WAITALL);

    if(server_mes->cmd == 200){
        printf("注册成功 \n");
    }else{
        printf("注册失败 \n");
    }

    return 0;
}



